package com.gee.solon.web.core.doc;

import com.github.xiaoymin.knife4j.solon.extension.OpenApiExtensionResolver;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.core.handle.Result;
import org.noear.solon.docs.DocDocket;
import org.noear.solon.docs.models.ApiContact;
import org.noear.solon.docs.models.ApiInfo;

/**
 * @author gepengjun
 * @since 2024/3/13 8:53
 */
@Configuration
@Inject(value = "knife4j")
public class DocConfig {

    @Inject
    OpenApiExtensionResolver openApiExtensionResolver;

    @Inject(value = "${solon.app.name}")
    private String appName;

    @Bean("appApi")
    public DocDocket docDocket(){
        return new DocDocket()
                .basicAuth(openApiExtensionResolver.getSetting().getBasic())
                .vendorExtensions(openApiExtensionResolver.buildExtensions())
                .groupName(appName)
                .info(
                        new ApiInfo().title("solon-web接口文档")
                                .description("solon-web接口文档")
                                .termsOfService("http://localhost:8080")
                                .contact(new ApiContact().name("gee")
                                        .url("www.gee.com")
                                        .email("gee@qq.com")
                                )
                                .version("1.0")
                )
                .globalResponseInData(true)
                .globalResult(Result.class)
                .apis("com.gee.solon.web.mgt.controller")
                ;
    }
}
